package com.company;

public class SocketDemo {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}
//class MyServer {
//    public static void main(String[] args) {
//        try (ServerSocket serverSocket = new ServerSocket(8080);
//             Socket socket = serverSocket.accept();
//             BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
//             BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
//        ) {
//            String line = reader.readLine();
//            System.out.println("line = " + line);
//            writer.write("收到了：" + line);
//            writer.newLine();
//            writer.flush();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//    }
//}
//
//class MyClient {
//    public static void main(String[] args) {
//        try (Socket socket = new Socket(InetAddress.getLocalHost(), 8080);
//             BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
//             BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
//        ) {
//            writer.write("hello world!");
//            writer.newLine();
//            writer.flush();
//            String readLine = reader.readLine();
//            System.out.println("readLine = " + readLine);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//    }
//}